package com.sfd.test.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.sfd.core.module.Result;
import com.sfd.test.service.OrderCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author haden
 * @date 2022/8/10 21:55
 **/
@RequestMapping("/orderCount")
@RestController
@Slf4j
public class OrderCountController {
    @Resource
    private OrderCountService orderCountService;

    @GetMapping("/create")
    public Result<String> create(@RequestParam("orderId") Long orderId, @RequestParam("balance") BigDecimal balance) {
        try {
            orderCountService.create(orderId, balance);
        } catch (Exception e) {
            return Result.busError(e.getMessage());
        }
        return Result.success();
    }

}
